//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by FernFlower decompiler)
//

package org.come.mouslisten;

import com.tool.Stall.Commodity;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;

import com.tool.tcpimg.InputBean;
import org.come.Frame.ZhuFrame;
import org.come.Jpanel.StallBuyJpanel;
import org.come.entity.Goodstable;
import org.come.entity.RoleSummoning;
import org.come.socket.Agreement;
import org.come.socket.SendMessageUntil;
import org.come.until.GsonUtil;
import org.come.until.MessagrFlagUntil;

public class CancelStallMouslisten implements MouseListener {
    private int type;
    private int index;
    private StallBuyJpanel buyJpanel;

    public CancelStallMouslisten(int index, int type, StallBuyJpanel buyJpanel) {
        this.index = index;
        this.type = type;
        this.buyJpanel = buyJpanel;
    }

    @Override
    public void mouseClicked(MouseEvent e) {
        Commodity commodity = this.buyJpanel.getStall().getCommodity(this.type, this.index);
        if (commodity != null) {
            this.buyJpanel.reset(commodity);
        }

    }

    @Override
    public void mousePressed(MouseEvent e) {
    }

    @Override
    public void mouseReleased(MouseEvent e) {
    }

    @Override
    public void mouseEntered(MouseEvent e) {
        MessagrFlagUntil.setMouse(MessagrFlagUntil.MOUSE12);
        Commodity commodity = this.buyJpanel.getStall().getCommodity(this.type, this.index);
        if (commodity != null) {
            Goodstable good = commodity.getGood();
            RoleSummoning pet = commodity.getPet();
            if (good != null) {
                ZhuFrame.getZhuJpanel().creatgoodtext(good);
            } else if (pet != null) {
               // ZhuFrame.getZhuJpanel().creatpettext(pet);
                InputBean inputBean=new InputBean();
                inputBean.setType(3);
                inputBean.setId(pet.getSid());
                String sendmes = Agreement.getAgreement().richMAgreement(GsonUtil.getGsonUtil().getgson().toJson(inputBean));
                SendMessageUntil.toServer(sendmes);
            }
        }

    }

    @Override
    public void mouseExited(MouseEvent e) {
        MessagrFlagUntil.setMouse(MessagrFlagUntil.MOUSE1);
        if (this.type == 0) {
            ZhuFrame.getZhuJpanel().cleargoodtext();
        } else if (this.type == 1) {
            ZhuFrame.getZhuJpanel().pettext();
        }

    }
}
